package ControlLayer;
import ModelLayer.ProductContainer;
import ModelLayer.Product;
import java.util.ArrayList;

/**
 * Vestbjerg project
 * @GroupB2 (UCN - Computer Science DMAJ0914) 
 */
public class ProductCtr
{
    // instance variables
    private ProductContainer productContainer;

    /**
     * Constructor for objects of class ProductCtr
     */
    public ProductCtr()
    {
        // initialise instance variables
        productContainer = ProductContainer.getInstance();
    }

    public void createProduct(String barcode, String name, String description,
    double price, int parLvl, int maxAmt, int discount, int stockAmt, String location) 
    {
        Product product = new Product(barcode, name, description, price, parLvl, maxAmt, discount, stockAmt, location);        
        productContainer.addProduct(product);
    }

    public Product findProduct(String barcode) 
    {
        return productContainer.findProduct(barcode);
    }

    public void updateProduct(Product product, String barcode, String name, String description,
    double price, int parLvl, int maxAmt, int discount, int stockAmt) 
    {
        product.setBarcode(barcode);
        product.setName(name);
        product.setDescription(description);
        product.setPrice(price);
        product.setParLvl(parLvl);
        product.setMaxAmt(maxAmt);
        product.setDiscount(discount);
        product.setStockAmt(stockAmt);            
    }

    public void deleteProduct(Product product) 
    {
        productContainer.deleteProduct(product);
    }

    public ArrayList<String> productSort() 
    {
        return productContainer.productSort();
    }
    
    public ArrayList<Product> getProductList() 
    {
     return productContainer.getProductList();
    }
}
